package ar.edu.utn.frsf.tpae.a2012.g05.entity;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name = "cja_aho")
@DiscriminatorValue("2")
public class CajaAhorro extends Cuenta{
	@Column(name = "cja_aho_int_mens", nullable = false, unique = true)
	private BigDecimal interesMensual;

	public CajaAhorro() {
		super();
		this.setTipoCuenta(Cuenta.CAJA_DE_AHORRO);
	}

	public CajaAhorro(boolean b) {
		this();
		if(b) {
			this.id = 1;
			this.numero = 123456;
			this.idCliente = 1;
			this.fechaApertura = new Date();
			this.saldoActual = new BigDecimal(123.45);
			this.interesMensual = new BigDecimal(0.2);
		}
	}

	public BigDecimal getInteresMensual() {
		return interesMensual;
	}

	public void setInteresMensual(BigDecimal interesMensual) {
		this.interesMensual = interesMensual;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result
				+ ((interesMensual == null) ? 0 : interesMensual.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		CajaAhorro other = (CajaAhorro) obj;
		if (interesMensual == null) {
			if (other.interesMensual != null)
				return false;
		} else if (!interesMensual.equals(other.interesMensual))
			return false;
		return true;
	}	
	
}
